package io.gitee.tianhaoran.chat.common.exception;

/**
 * Ai Chat 异常
 * <p>
 * 作者：沈自在
 **/
public class ChatException extends RuntimeException {

    private static final long serialVersionUID = 4898111111676070332L;

    /**
     * 全局错误码
     */
    private Integer code;
    /**
     * 错误提示
     */
    private String message;

    /**
     * 无参数
     */
    public ChatException() {
        super();
    }

    /**
     * 描述、原因
     */
    public ChatException(String message, Throwable cause) {
        super(message, cause);
    }

    /**
     * 单描述
     */
    public ChatException(String message) {
        super(message);
    }

    /**
     * 单原因
     */
    public ChatException(Throwable cause) {
        super(cause);
    }

    /**
     *
     */
    public ChatException(ErrorCode errorCode) {
        this.code = errorCode.getCode();
        this.message = errorCode.getMsg();
    }

    /**
     *
     */
    public ChatException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 链式构建
     */
    public ChatException setCode(Integer code) {
        this.code = code;
        return this;
    }

    /**
     * 链式构建
     */
    public ChatException setMessage(String message) {
        this.message = message;
        return this;
    }

    /**
     *
     */
    @Override
    public String getMessage() {
        return message;
    }
}
